home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 19 June 1997
- // Author: bwk
- //
- // Description:
- // This script initializes the Channel box. Initialization involves
- // determining the initial Channel box preferences, creating the UI
- // and setting the initial visibility.
- //
-
- global proc showChannelBox(int $show)
- //
- // Description:
- //
- // *** Obsolete ***
- //
- // *** Use runTimeCommand ToggleChannelsLayers instead ***
- //
- // Arguments:
- // show - True if the Channel Box should be shown, false if the Channel
- // Box should become hidden.
- //
- {
- warning -showLineNumber true
- ("The procedure \"showChannelBox()\" is now obsolete. "
- + "Use the command \"ToggleChannelsLayers\" instead.");
- }
-
- global proc int channelBoxVisibilityStateChange(
- int $newState,
- string $layout)
- //
- // Description:
- // This procedure is called whenever the visibility state of the
- // Channel Box is changed.
- //
- // Arguments:
- // newState - The new visibile state of the Channel Box.
- //
- // layout - The parent layout for the Channel Box.
- //
- // Returns:
- // true - If the change of state is to be allowed.
- //
- // false - If the state change is rejected.
- //
- {
- int $result = true;
-
- // Defer these commands because this proc is called when the visibility
- // state is about to change. This proc must return true to accept
- // the state change. After this proc returns then restore the
- // panel focus and update the pref menu.
- //
- evalDeferred("restoreLastPanelWithFocus(); updatePrefsMenu()");
-
- return $result;
- }
-
- // Procedure Name:
- // checkSpeedButton
- //
- // Description Name;
- // Sets the button which visualizes the current speed which is
- // used for channel box sliders
- //
- // Input Value:
- // which speed is currently set
- //
- // Output Value:
- // None
- //
- global proc checkSpeedButton ( string $speed, int $useManips )
- {
- switch ($speed){
- case "slow":
- channelBox -e -speed 0.1 mainChannelBox;
- symbolButton -e
- -i "channelBoxSlow.xpm"
- -c ("channelBoxSettings medium " + $useManips )
- cbSpeedButton;
- break;
- case "medium":
- channelBox -e -speed 1 mainChannelBox;
- symbolButton -e
- -i "channelBoxMedium.xpm"
- -c ("channelBoxSettings fast " + $useManips )
- cbSpeedButton;
- break;
- case "fast":
- channelBox -e -speed 10 mainChannelBox;
- symbolButton -e
- -i "channelBoxFast.xpm"
- -c ("channelBoxSettings slow " + $useManips )
- cbSpeedButton;
- break;
- default:
- symbolButton -e
- -i "channelBoxUnknownSpeed.xpm"
- -c ("channelBoxSettings medium " + $useManips )
- cbSpeedButton;
- break;
-
- }
- }
-
-
- // Procedure Name:
- // checkManipButton
- //
- // Description Name;
- // Sets the button which visualize which manipType is
- // used in the channel box.
- //
- // Input Value:
- // which manipType is currently used
- //
- // Output Value:
- // None
- //
-
-
-
- global proc checkManipButton ( int $state )
- {
- switch ($state){
- case 0:
- symbolButton -e -i "channelBoxNoManips.xpm"
- -c "channelBoxSettings useManips 1"
- cbManipsButton;
- break;
- case 1:
- symbolButton -e -i "channelBoxInvisibleManips.xpm"
- -c "channelBoxSettings useManips 2"
- cbManipsButton;
- break;
- case 2:
- symbolButton -e -i "channelBoxUseManips.xpm"
- -c "channelBoxSettings useManips 0"
- cbManipsButton;
- break;
- }
- }
-
- //
- // Procedure Name:
- // setChannelLongName
- //
- // Description:
- // Sets the Channel box long/short name flag and also changes the
- // width of the Channel box and sets the optionVar for this setting.
- //
- // Input Arguments:
- // state - 0 = short, 1 = nice, 2 = long
- //
- // Return Value:
- // None.
- //
- global proc setChannelLongName( int $state )
- {
- global string $gChannelBoxName;
- global int $gChannelsLayersWidth;
-
- int $width;
-
- // Query the current "name" state of the Channel box.
- //
- int $longNames = `channelBox -query -longNames $gChannelBoxName`;
- int $niceNames = `channelBox -query -niceNames $gChannelBoxName`;
-
- // Check for a change.
- //
- if ($niceNames && $state == 1) return;
- if (!$niceNames && $longNames && $state == 2) return;
- if (!$niceNames && !$longNames && $state == 0) return;
-
- if( $state == 2 ) {
- $width = 180;
- channelBox -e -ln true -nn false $gChannelBoxName;
- optionVar -iv channelsLongName 2;
-
- } else if( $state == 1 ) {
- $width = 140;
- channelBox -e -ln true -nn true $gChannelBoxName;
- optionVar -iv channelsLongName 1;
-
- } else {
- $width = 140;
- channelBox -e -ln false -nn false $gChannelBoxName;
- optionVar -iv channelsLongName 0;
- }
-
- setChannelsLayersWidth($width);
- }
-
- global proc initChannelBoxButtons()
- //
- // Handle initializing the icons at the top of the channel box
- //
- {
- // Get the current channel box settings to set
- // the buttons at the top of the channelbox to
- // the appropriate values
- //
- string $manipType = `channelBox -q -useManips mainChannelBox`;
- int $useManips;
- switch ($manipType){
- case "none":
- $useManips = 0;
- break;
- case "invisible":
- $useManips = 1;
- break;
- default:
- $useManips = 2;
- break;
- }
- float $speed = `channelBox -q -speed mainChannelBox`;
- string $speedMode;
- if ($speed == 0.1) {
- $speedMode = "slow";
- } else if ($speed == 1.0) {
- $speedMode = "medium";
- } else if ($speed == 10.0) {
- $speedMode = "fast";
- } else {
- $speedMode = "unknown";
- }
-
- int $hyperbolic = `channelBox -q -hyperbolic mainChannelBox`;
-
- // Update the buttons
- //
- symbolButton -edit
- -enable true
- cbManipsButton;
- checkManipButton ($useManips);
-
- symbolButton -edit
- -enable ( $useManips == 1 )
- cbSpeedButton;
- checkSpeedButton $speedMode $useManips;
-
- symbolCheckBox -edit
- -v $hyperbolic
- -enable ( $useManips == 1 )
- cbHyperbolicButton;
- }
-
- global proc channelBoxSettings( string $cmd, int $state )
- //
- // Handle updating the icons at the top of the channel
- // box when menu entries are selected in the popup menu
- {
- switch( $cmd ) {
- case "slow":
- checkSpeedButton "slow" $state;
- break;
- case "medium":
- checkSpeedButton "medium" $state;
- break;
- case "fast":
- checkSpeedButton "fast" $state;
- break;
- case "hyperbolic":
- channelBox -e -hyperbolic $state mainChannelBox;
- symbolCheckBox -e -v $state cbHyperbolicButton;
- break;
- case "useManips":
- checkManipButton ($state);
-
- if ( $state == 0 ) {
- //
- // Manips are off - disable the speed settings
- //
- symbolButton -e -enable false cbSpeedButton;
- symbolCheckBox -e -enable false cbHyperbolicButton;
- channelBox -e -useManips "none" mainChannelBox;
-
- } else if( $state == 1 ) {
- //
- // Manips are invisible only - enable the speed settings
- //
- symbolButton -e -enable true cbSpeedButton;
- symbolCheckBox -e -enable true cbHyperbolicButton;
- channelBox -e -useManips "invisible" mainChannelBox;
-
- } else {
- //
- // Manips are standard - disable the speed settings
- //
- symbolButton -e -enable false cbSpeedButton;
- symbolCheckBox -e -enable false cbHyperbolicButton;
- channelBox -e -useManips "standard" mainChannelBox;
- }
- break;
- }
- }
-
- global proc buildChannelObjectMenu( string $parent ) {
- //
- // Builds a menu with the last 20 items on the selection
- // list, and allows the user to switch which objects
- // values are being shown. In effect, it switches
- // the lead object, by "adding" it to the selection
- // list, which places it last in the selection list
- //
- setParent -m $parent;
- menu -e -dai $parent;
- int $size;
-
- string $sel[] = `ls -sl -tail 10`;
- $size = `size( $sel )`;
-
- if( `isTrue SomethingSelected` ) {
- menuItem -l $sel[ $size-1 ] -c ( "select -add " + $sel[ $size-1 ]);
- menuItem -ob true -c ( "select -add "+$sel[$size-1]+"; editSelected" );
- menuItem -d true;
-
- for($i = $size-2; $i >= 0; $i--) {
- menuItem -l $sel[ $i ] -c ( "select -add " + $sel[ $i ] );
- menuItem -ob true -c ( "select -add "+$sel[$i]+"; editSelected" );
- }
- } else {
- menuItem -l "Nothing selected";
- }
- }
-
- // Now, the main script to be executed. Not that this is NOT a proc.
- //
- {
- // Declare referenced or returned globals.
- //
- global string $gChannelBoxName;
- global string $gChannelBoxForm;
-
- // Determine values of option variables
- //
- int $channelsLongName = `optionVar -query channelsLongName`;
- int $precision = `optionVar -q channelsPrecision`;
- int $numWidth = `optionVar -q channelsFieldWidth`;
-
- // Create a menu bar layout for the Channel box.
- //
- string $menuBarLayout = `menuBarLayout`;
-
- string $columnName;
- int $nSections;
-
- // Add a menu to the menuBarLayout at the top of the
- // channel box. NOTE: can't make this menu a tearoff,
- // as it dynamically updates based on channels selected
- // in the channel box.
- //
- string $menu = `menu -label "Channels"
- -familyImage "menuIconChannels.xpm"`;
- menu -edit -pmc ("generateChannelMenu " + $menu + " 0" ) $menu;
- setParent -m ..;
-
- $menu = `menu -l "Object"
- -aob true
- -familyImage "menuIconObject.xpm"`;
- menu -e -pmc ( "buildChannelObjectMenu " + $menu ) $menu;
- setParent -m ..;
-
- // Build the Channel box, with a frame layout around it.
- //
- string $boxName = `frameLayout
- -labelVisible false
- -collapsable false
- -collapse false
- -marginHeight 1
- -marginWidth 1
- -borderStyle "etchedIn"`;
-
- // Create the Channel box.
- //
- $gChannelBoxName = `channelBox -st true
- -longNames ($channelsLongName==2)
- -niceNames ($channelsLongName==1)
- -precision $precision
- -fieldWidth $numWidth
- mainChannelBox`;
-
- // Add the same menu that is in the menuBarLayout as a popup for the
- // whole channel box.
- //
- $menu = `popupMenu -parent $gChannelBoxName`;
- menu -edit -postMenuCommand ( "generateChannelMenu " + $menu + " 1" ) $menu;
-
- setParent ..;
-
- // Layout the separator, Channel box and the buttons.
- //
- formLayout -edit
- -attachForm $menuBarLayout "top" 0
- -attachForm $menuBarLayout "left" 0
- -attachForm $menuBarLayout "bottom" 0
- -attachForm $menuBarLayout "right" 0
- $gChannelBoxForm;
-
- initChannelBoxButtons();
- }
-
-